# pymysql
# 帮助我们连接数据库mysql
# pip install pymysql

import pymysql
from pymysql.cursors import DictCursor

with pymysql.Connect(
    host="127.0.0.1",
    user="root",
    password="123456",
    database="walkertest",
    cursorclass=DictCursor
) as connect:
    cursor = connect.cursor()  # 获取游标，通过游标来执行sql
    # sql = "select app, id  from django_migrations;"
    # cursor.execute(sql)

    # 获取查询结果
    # cursor.fetchone()获取一条数据，游标移动，再次获取时获取下一条
    # print(cursor.fetchone())
    # print(cursor.fetchone())

    # cursor.fetchall()获取从游标开始到最后的所有数据
    # print(cursor.fetchall())
    # sql = "insert into xxx () value()"
    # cursor.execute(sql)
    #
    # connect.commit()
